﻿var IconB = "#fUI/UIMiniGame/starPlanetRPS/heart#";//红心桃心
var IconA = "#fEffect/CharacterEff/1112926/0/0#"; //   红星
var IconC = "#fUI/UIWindow2.img/Quest/quest_info/summary_icon/startcondition#"; //开始条件
var status = 0;
var typed;
var txt;
var S, A, B, C, D, E, F, G;

var itemlistA = Array(                                          //武器租凭
    Array(1, 1542108, "武器", 30, 8, 5, 7),
    Array(1, 1212115, "武器", 30, 8, 5, 7),
    Array(1, 1222109, "武器", 30, 6, 5, 7),
    Array(1, 1232109, "武器", 30, 8, 5, 7),
    Array(1, 1242116, "武器", 30, 8, 5, 7),
    Array(1, 1302333, "武器", 30, 10, 5, 7),
    Array(1, 1312199, "武器", 30, 10, 5, 7),
    Array(1, 1332274, "武器", 30, 8, 5, 7),
    Array(1, 1322250, "武器", 30, 10, 5, 7),
    Array(1, 1342101, "武器", 30, 10, 5, 7),
    Array(1, 1362135, "武器", 30, 6, 5, 7),
    Array(1, 1372222, "武器", 30, 10, 5, 7),
    Array(1, 1382259, "武器", 30, 10, 5, 7),
    Array(1, 1402251, "武器", 30, 8, 5, 7),
    Array(1, 1412177, "武器", 30, 10, 5, 7),
    Array(1, 1422184, "武器", 30, 10, 5, 7),
    Array(1, 1432214, "武器", 30, 8, 5, 7),
    Array(1, 1442268, "武器", 30, 4, 5, 7),
    Array(1, 1452252, "武器", 30, 12, 5, 7),
    Array(1, 1462239, "武器", 30, 12, 5, 7),
    Array(1, 1472261, "武器", 30, 6, 5, 7),
    Array(1, 1492231, "武器", 30, 12, 5, 7),
    Array(1, 1522138, "武器", 30, 8, 5, 7),
    Array(1, 1532144, "武器", 30, 10, 5, 7),
    Array(1, 1482216, "武器", 30, 10, 5, 7),
    Array(1, 1262017, "武器", 30, 10, 5, 7)
                    );
var itemlistB = Array(                                          //武器租凭
    Array(1, 1542108, "点卷", 99999, 8, 5, 7),
    Array(1, 1212115, "点卷", 99999, 8, 5, 7),
    Array(1, 1222109, "点卷", 99999, 6, 5, 7),
    Array(1, 1232109, "点卷", 99999, 8, 5, 7),
    Array(1, 1242116, "点卷", 99999, 8, 5, 7),
    Array(1, 1302333, "点卷", 99999, 10, 5, 7),
    Array(1, 1312199, "点卷", 99999, 10, 5, 7),
    Array(1, 1332274, "点卷", 99999, 8, 5, 7),
    Array(1, 1322250, "点卷", 99999, 10, 5, 7),
    Array(1, 1342101, "点卷", 99999, 10, 5, 7),
    Array(1, 1362135, "点卷", 99999, 6, 5, 7),
    Array(1, 1372222, "点卷", 99999, 10, 5, 7),
    Array(1, 1382259, "点卷", 99999, 10, 5, 7),
    Array(1, 1402251, "点卷", 99999, 8, 5, 7),
    Array(1, 1412177, "点卷", 99999, 10, 5, 7),
    Array(1, 1422184, "点卷", 99999, 10, 5, 7),
    Array(1, 1432214, "点卷", 99999, 8, 5, 7),
    Array(1, 1442268, "点卷", 99999, 4, 5, 7),
    Array(1, 1452252, "点卷", 99999, 12, 5, 7),
    Array(1, 1462239, "点卷", 99999, 12, 5, 7),
    Array(1, 1472261, "点卷", 99999, 6, 5, 7),
    Array(1, 1492231, "点卷", 99999, 12, 5, 7),
    Array(1, 1522138, "点卷", 99999, 8, 5, 7),
    Array(1, 1532144, "点卷", 99999, 10, 5, 7),
    Array(1, 1482216, "点卷", 99999, 10, 5, 7),
    Array(1, 1262017, "点卷", 99999, 10, 5, 7)
                    );
var itemlistC = Array(                                          //武器租凭
    Array(1, 1542108, "抵押卷", 100000, 8, 5, 7),
    Array(1, 1212115, "抵押卷", 100000, 8, 5, 7),
    Array(1, 1222109, "抵押卷", 100000, 6, 5, 7),
    Array(1, 1232109, "抵押卷", 100000, 8, 5, 7),
    Array(1, 1242116, "抵押卷", 100000, 8, 5, 7),
    Array(1, 1302333, "抵押卷", 100000, 10, 5, 7),
    Array(1, 1312199, "抵押卷", 100000, 10, 5, 7),
    Array(1, 1332274, "抵押卷", 100000, 8, 5, 7),
    Array(1, 1322250, "抵押卷", 100000, 10, 5, 7),
    Array(1, 1342101, "抵押卷", 100000, 10, 5, 7),
    Array(1, 1362135, "抵押卷", 100000, 6, 5, 7),
    Array(1, 1372222, "抵押卷", 100000, 10, 5, 7),
    Array(1, 1382259, "抵押卷", 100000, 10, 5, 7),
    Array(1, 1402251, "抵押卷", 100000, 8, 5, 7),
    Array(1, 1412177, "抵押卷", 100000, 10, 5, 7),
    Array(1, 1422184, "抵押卷", 100000, 10, 5, 7),
    Array(1, 1432214, "抵押卷", 100000, 8, 5, 7),
    Array(1, 1442268, "抵押卷", 100000, 4, 5, 7),
    Array(1, 1452252, "抵押卷", 100000, 12, 5, 7),
    Array(1, 1462239, "抵押卷", 100000, 12, 5, 7),
    Array(1, 1472261, "抵押卷", 100000, 6, 5, 7),
    Array(1, 1492231, "抵押卷", 100000, 12, 5, 7),
    Array(1, 1522138, "抵押卷", 100000, 8, 5, 7),
    Array(1, 1532144, "抵押卷", 100000, 10, 5, 7),
    Array(1, 1482216, "抵押卷", 100000, 10, 5, 7),
    Array(1, 1262017, "抵押卷", 100000, 10, 5, 7)
                    );
var itemlistD = Array(                                          //武器租凭
    Array(1, 1542108, "租凭卷", 1, 8, 5, 7),
    Array(1, 1212115, "租凭卷", 1, 8, 5, 7),
    Array(1, 1222109, "租凭卷", 1, 6, 5, 7),
    Array(1, 1232109, "租凭卷", 1, 8, 5, 7),
    Array(1, 1242116, "租凭卷", 1, 8, 5, 7),
    Array(1, 1302333, "租凭卷", 1, 10, 5, 7),
    Array(1, 1312199, "租凭卷", 1, 10, 5, 7),
    Array(1, 1332274, "租凭卷", 1, 8, 5, 7),
    Array(1, 1322250, "租凭卷", 1, 10, 5, 7),
    Array(1, 1342101, "租凭卷", 1, 10, 5, 7),
    Array(1, 1362135, "租凭卷", 1, 6, 5, 7),
    Array(1, 1372222, "租凭卷", 1, 10, 5, 7),
    Array(1, 1382259, "租凭卷", 1, 10, 5, 7),
    Array(1, 1402251, "租凭卷", 1, 8, 5, 7),
    Array(1, 1412177, "租凭卷", 1, 10, 5, 7),
    Array(1, 1422184, "租凭卷", 1, 10, 5, 7),
    Array(1, 1432214, "租凭卷", 1, 8, 5, 7),
    Array(1, 1442268, "租凭卷", 1, 4, 5, 7),
    Array(1, 1452252, "租凭卷", 1, 12, 5, 7),
    Array(1, 1462239, "租凭卷", 1, 12, 5, 7),
    Array(1, 1472261, "租凭卷", 1, 6, 5, 7),
    Array(1, 1492231, "租凭卷", 1, 12, 5, 7),
    Array(1, 1522138, "租凭卷", 1, 8, 5, 7),
    Array(1, 1532144, "租凭卷", 1, 10, 5, 7),
    Array(1, 1482216, "租凭卷", 1, 10, 5, 7),
    Array(1, 1262017, "租凭卷", 1, 10, 5, 7)
                    );
function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {


    //if (cm.haveItem(4001485, 10)) { //ID 数量
	if (cm.getHyPay(1) >= 30) { //ID 数量
        C = "#r[ 达　标 ]#k";
    } else {
        C = "#b[ 未达标 ]#k";
    }
    if (cm.getPlayer().getCSPoints(1) >= 99999) {
        D = "#r[ 达　标 ]#k";
    } else {
        D = "#b[ 未达标 ]#k";
    }
    if (cm.getPlayer().getCSPoints(2) >= 100000) {
        E = "#r[ 达　标 ]#k";
    } else {
        E = "#b[ 未达标 ]#k";
    }
    if (cm.haveItem(4001485, 1)) {
        F = "#r[ 达　标 ]#k";
    } else {
        F = "#b[ 未达标 ]#k";
    }

    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1)
            status++;
        else
            status--;
        if (status == 0) {
            txt = "\r\n\r\n " + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + "\r\n";
            txt += "\t\t\t\t\t　#i4001485#\r\n";
            txt += "　#d尊敬的 [ #r#h ##d ] 玩家 欢迎光临 #r豪品租凭中心#k\r\n\r\n";
            txt += "　 #r#L0#■ 租凭中心 ■#b　详情办理方式介绍及说明#l\r\n\r\n";
            txt += "　 #r#L1#■ 租凭中心 ■#d　选购道具并办理租凭手续#l\r\n\r\n";
            txt += "\r\n\r\n " + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + "\r\n\r\n";
            txt += "　 #r管理员提示：#b单击 [ #r是#b ] 租凭 单击 [ #r否#b ] 返回#k\r\n";
            cm.sendYesNoS(txt, 2)
        } else if (status == 1) {
            if (selection == 0) {
                txt = "\r\n\r\n " + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + "\r\n";
                txt += "\t\t #d#i4001485# 当前拥有元宝：#r" + cm.getItemQuantity(4001485) + "#d　#i4001485#\r\n";
                txt += "　#d尊敬的 [ #r#h ##d ] 玩家 请仔细阅读租凭条款#k\r\n\r\n";
                txt += "　 #r■ 租凭条款说明 ■#k\r\n\r\n";
                txt += "　#b租凭所需道具 #r元宝 租凭票 抵用卷 点卷 金币#d等方式#k\r\n";
                txt += "　#b租凭道具时间 #d所持有的货币定位  #r属性都爆炸噢#k\r\n";
                txt += "　#b租凭道具价位 #d请选择每种不同的类型租凭时查询#k \r\n";
                txt += "\r\n\r\n " + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + "\r\n\r\n";
                txt += "　 　#r管理员提示：#b单击 [ #r确认#b ] 返回初始页面#k\r\n";
                cm.sendOkS(txt, 3);
                status = -1;
            } else if (selection == 1) {
                txt = "\r\n\r\n " + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + "\r\n";
                txt += "\t\t\t\t\t　 #i4250002#\r\n";
                txt += "　　#d尊敬的 [ #r#h ##d ] 玩家 请选择你需定制的类型#k\r\n\r\n";
                txt += "#L0##r" + IconA + " 武器 " + IconA + "#b [ 元宝 ※ 点卷 ※ 抵用卷 ※ 租凭票 ]#l\r\n";
                txt += "#L1##r" + IconA + " 饰品 " + IconA + "#b [ 元宝 ※ 点卷 ※ 抵用卷 ※ 租凭票 ]#l\r\n";
                txt += "#L2##r" + IconA + " 防具 " + IconA + "#b [ 元宝 ※ 点卷 ※ 抵用卷 ※ 租凭票 ]#l\r\n";
                txt += "\r\n\r\n " + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + "\r\n\r\n";
                txt += "　 #r管理员提示：#b 新品道具等待出售 敬请期待 #k\r\n";
                cm.sendYesNoS(txt, 2)
            }
        } else if (status == 2) {
            if (selection == 0) {
                S = 0;
            } else if (selection == 1) {
                S = 1;
                cm.playerMessage(1, "豪品租凭中心\r\n\r\n敬请期待");
                cm.dispose();
                return;
            } else if (selection == 2) {
                S = 2;
                cm.playerMessage(1, "豪品租凭中心\r\n\r\n敬请期待");
                cm.dispose();
                return;
            }
            txt = "\r\n\r\n " + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + "\r\n\r\n";
            txt += "\t\t\t\t\t　 #i4250002#\r\n\r\n";
            txt += "　　#d尊敬的 [ #r#h ##d ] 玩家 请选择与你职业相同的武器#k\r\n\r\n";
            txt += "　 　　　　　　　#r■ 武器租凭中心 ■#k\r\n";
            txt += "　#L0##r" + IconA + " 元　宝 " + IconA + "#b 　[ 豪品租凭中心支付类型 ]#l\r\n";
            txt += "　#L1##r" + IconA + " 点　卷 " + IconA + "#b 　[ 豪品租凭中心支付类型 ]#l\r\n";
            txt += "　#L2##r" + IconA + " 抵用卷 " + IconA + "#b 　[ 豪品租凭中心支付类型 ]#l\r\n";
           // txt += "　#L3##r" + IconA + " 租凭票 " + IconA + "#b 　[ 豪品租凭中心支付类型 ]#l\r\n";
            txt += "\r\n\r\n " + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + "\r\n\r\n";
            txt += "　 　　#r管理员提示：#b请选择租凭道具支付类型#k\r\n";
            cm.sendSimpleS(txt, 3);
        } else if (status == 3) {
            if (selection == 0) {
                B = 0;
            } else if (selection == 1) {
                B = 1;
            } else if (selection == 2) {
                B = 2;
            } else if (selection == 3) {
                B = 3;
            }

            txt = "\r\n\r\n " + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + "\r\n\r\n";
            txt += "\t\t\t\t\t　 #i4250002#\r\n\r\n";
            txt += "　#d尊敬的 [ #r#h ##d ] 玩家 请选择与你职业相同的武器#k\r\n\r\n";
            txt += "　 　　　　　　　#r■ 武器租凭中心 ■#k\r\n";
            txt += "#d#n\r\n　　　　道具　　　 　　　　类型　　时间　　支付方式\r\n";
            if (S == 0) {
				if (B == 0) {
                G = itemlistA;
				} else if (B == 1) {
			    G = itemlistB;
				} else if (B == 2) {
				G = itemlistC;	
				} else if (B == 3) {
				G = itemlistD;		
				}	
            } else if (S == 1) {
                G = itemlistB;
            } else if (S == 2) {
                G = itemlistC;
            }
            for (var i = 0; i < G.length; i++) {

                txt += "#L" + i + "##d#z" + G[i][1] + "#";

                for (var j = G[i][4]; j > 0; j--) {
                    txt += " ";
                }
                txt += "#r" + G[i][2] + "#b";

                if (G[i][2] - 5 < 0) {
                    txt += " ";
                }

                for (var j = G[i][5]; j > 0; j--) {
                    txt += " ";
                }
                txt += G[i][3];

                if (G[i][2] - 5 < 0) {
                    txt += " ";
                }
                for (var j = G[i][6]; j > 0; j--) {
                    txt += " ";
                }
                if (B == 0) {
                    txt += "#r元　宝#k";
                } else if (B == 1) {
                    txt += "#r点　卷#k";
                } else if (B == 2) {
                    txt += "#r抵用卷#k";
                } else if (B == 3) {
                    txt += "#r租凭票#k";
                }

                if (G[i][2] - 5 < 0) {
                    txt += " ";
                }
                txt += "#k\r\n#l";
            }
            txt += "\r\n\r\n " + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + "\r\n\r\n";
            txt += "　 　　#r管理员提示：#b单击 [ #r是#b ] 进行购买租凭#k\r\n";
            cm.sendSimpleS(txt, 3);
        } else if (status == 4) {
            A = selection;
            var txt = IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + "\r\n\r\n";
            txt += "\t\t\t\t\t　" + IconC + "\r\n\r\n";
            txt += "#r\t管理员提示：当前选择 [ #b#z" + itemlistA[A][1] + "##r ]#k#n\r\n\r\n";
            txt += "#b\t" + C + "　#d当前拥有元　宝数量：※　#r" + cm.getHyPay(1) + "#k\r\n";
            txt += "#b\t" + D + "　#d当前拥有点　卷数量：※　#r" + cm.getPlayer().getCSPoints(1) + "#k\r\n";
            txt += "#b\t" + E + "　#d当前拥有抵用卷数量：※　#r" + cm.getPlayer().getCSPoints(2) + "#k\r\n";
            txt += "#b\t" + F + "　#d当前拥有租凭票数量：※　#r" + cm.getItemQuantity(4001485) + "#k\r\n";
            txt += "\r\n" + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + IconB + "\r\n";
            txt += " #r#e管理员提示：#b#n确认无误请单击 [ 下一步 ] 进行道具租凭#k";
            cm.sendSimpleS(txt, 2);
        } else if (status == 5) {
            if (B == 0) {
                if (cm.getHyPay(1) >= 30) {
					cm.addHyPay(30);//扣多少元宝
                } else {
                    cm.playerMessage(1, "豪品租凭中心\r\n\r\n抱歉尊敬的玩家\r\n\r\n您的 元宝 数量不足\r\n\r\n请携带 元宝 光顾");
                    cm.dispose();
                    return;
                }
            } else if (B == 1) {
                if (cm.getPlayer().getCSPoints(1) >= 99999) {
                    cm.gainNX(1, -99999);
                } else {
                    cm.playerMessage(1, "豪品租凭中心\r\n\r\n抱歉尊敬的玩家\r\n\r\n您的 点卷 数量不足\r\n\r\n请携带 点卷 光顾");
                    cm.dispose();
                    return;
                }
            } else if (B == 2) {
                if (cm.getPlayer().getCSPoints(2) >= 100000) {
                    cm.gainNX(2, -100000);
                } else {
                    cm.playerMessage(1, "豪品租凭中心\r\n\r\n抱歉尊敬的玩家\r\n\r\n您的 抵用卷 数量不足\r\n\r\n请携带 抵用卷 光顾");
                    cm.dispose();
                    return;
                }
            } else if (B == 1) {
                if (cm.haveItem(4001485, 1)) {
                    cm.gainItem(4001485, -1);
                } else {
                    cm.playerMessage(1, "豪品租凭中心\r\n\r\n抱歉尊敬的玩家\r\n\r\n您的 租凭票 数量不足\r\n\r\n请携带 租凭票 光顾");
                    cm.dispose();
                    return;
                }
            }
            var ii = cm.getItemInfo();
            var toDrop = ii.randomizeStats(ii.getEquipById(itemlistA[A][1])).copy();            //生成一个Equip类
            toDrop.setStr(200);                                                         //装备力量
            toDrop.setDex(200);                                                         //装备敏捷
            toDrop.setInt(200);                                                         //装备智力
            toDrop.setLuk(200);                                                         //装备运气
            toDrop.setMatk(200);                                                        //魔法攻击
            toDrop.setWatk(200);                                                        //物理攻击 
            toDrop.setEnhance(100);                                                      //星级
           // toDrop.setAcc(5);                                                          //命中
            var timeStamp = java.lang.System.currentTimeMillis();
           // var expirationDate = timeStamp + itemlistA[A][3] * 86400 * 34;
           // toDrop.setExpiration(expirationDate);
            toDrop.setOwner("豪品租凭中心");                                            //签名
            toDrop.setBossDamage(50);                                                  //Boss 攻击百分比%
            toDrop.setIgnorePDR(20);                                                    //无视怪物防御
            toDrop.setTotalDamage(10);                                                  //总伤害
            toDrop.setLimitBreak(2100000000);                                            //伤害上限
            cm.addFromDrop(cm.getC(), toDrop, false);
            cm.playerMessage(1, "豪品租凭中心\r\n\r\n恭喜您 \r\n\r\n你的道具已给予租凭 永久使用权");
            cm.getMap().startMapEffect("恭喜玩家 " + cm.getChar().getName() + " 成功租得土豪武器", 5120002);
            cm.worldSpouseMessage(0x15, "『土豪新闻』 : 恭喜土豪 " + cm.getChar().getName() + " 成功租凭土豪武器永久权");
            cm.dispose();

        }
    }
}
